package x_yeyue.utils;//package utils;

import com.sun.management.GarbageCollectionNotificationInfo;
import x_yeyue.obj.BossBullet;
import x_yeyue.obj.Enemy1Obj;
import x_yeyue.obj.GameObj;
import x_yeyue.obj.ShellObj;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

// 游戏工具类
public class GameUtils {
//    public static Image bgImg = Toolkit.getDefaultToolkit().getImage("imgs/bg.jpg");
    public static Image bgImg = loadImage("imgs/bg.jpg");
    // 获取boss图片
//    public static Image bossImg = Toolkit.getDefaultToolkit().getImage("imgs/boss.png");
    public static Image bossImg = loadImage("imgs/boss.png");
    // 获取爆炸图片
//    public static Image explodeImg = Toolkit.getDefaultToolkit().getImage("imgs/explode/e6.gif");
    public static Image explodeImg = loadImage("imgs/explode/e6.gif");
    // 获取我方飞机图片
//    public static Image planeImg = Toolkit.getDefaultToolkit().getImage("imgs/plane.png");
    public static Image planeImg = loadImage("imgs/plane.png");
    // 获取我方子弹的图片
    public static Image shellImg = loadImage("imgs/shell.png");
    // 获取敌方小飞机的图片
    public static Image enemy1Img = loadImage("imgs/enemy1.png");
    // 获取boss子弹的图片
    public static Image bossBulletImg = loadImage("imgs/bossbullet.png");

    // 创建我方飞机子弹的集合
    public static ArrayList<ShellObj> shellObjList = new ArrayList<>();
    // 所有元素的集合
    public static ArrayList<GameObj> gameObjList = new ArrayList<>();
    // 敌方小飞机的集合
    public static ArrayList<Enemy1Obj> enemy1ObjsList = new ArrayList<>();
    // 移除游戏窗口元素的集合
    public static ArrayList<GameObj> removeList = new ArrayList<>();
    // 创建boss子弹的集合
    public static ArrayList<BossBullet> bossBulletList = new ArrayList<>();


    // 绘制文字方法
    public static void drawWord(Graphics gImage, String str, Color color, int size, int x, int y){
        gImage.setColor(color);
        gImage.setFont(new Font("仿宋", Font.BOLD, size));
        gImage.drawString(str, x, y);
    }
    // 加载图片的静态方法
    public static Image loadImage(String path) {
        try {
            return ImageIO.read(new File(path));
        } catch (IOException e) {
            System.err.println("图片加载失败: " + path);
            e.printStackTrace();
            return null;
        }
    }
}
